package com.qf.sportsevent.entity;

import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.AbsoluteSizeSpan;
import android.view.View;

import com.qf.sportsevent.util.FormatUtils;

/**
 * Created by Administrator on 2016/12/16.
 */

public class NewsContestEntity {
    private int contest_id;
    private int home_scores;
    private int away_scores;
    private int status;
    private String start_time;
    private NewsTeamInfoEntity h_t;
    private NewsTeamInfoEntity a_t;
    private int room_id;
    private boolean isSpecial;

    public int getHome_scores() {
        return home_scores;
    }

    public void setHome_scores(int home_scores) {
        this.home_scores = home_scores;
    }

    public int getAway_scores() {
        return away_scores;
    }

    public void setAway_scores(int away_scores) {
        this.away_scores = away_scores;
    }

    public String getStart_time() {
        return start_time;
    }

    public void setStart_time(String start_time) {
        this.start_time = start_time;
    }

    public NewsTeamInfoEntity getH_t() {
        return h_t;
    }

    public void setH_t(NewsTeamInfoEntity h_t) {
        this.h_t = h_t;
    }

    public NewsTeamInfoEntity getA_t() {
        return a_t;
    }

    public void setA_t(NewsTeamInfoEntity a_t) {
        this.a_t = a_t;
    }

    public int getContest_id() {
        return contest_id;
    }

    public void setContest_id(int contest_id) {
        this.contest_id = contest_id;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getRoom_id() {
        return room_id;
    }

    public void setRoom_id(int room_id) {
        this.room_id = room_id;
    }

    public boolean isSpecial() {
        return isSpecial;
    }

    public void setSpecial(boolean special) {
        isSpecial = special;
    }


    public String getTitle(){
        if(status!=-1 && status!=0){
            String stage = FormatUtils.formatNumberToChinese(status);
            if (stage != null) {
                return "第"+stage+"节";
            }
        }

        if (start_time != null) {
            return FormatUtils.checkDate(start_time);
        }
        return null;
    }

    public SpannableString getScores(){
        int textSize = isSpecial ? 18 : 14;
        String divider = isSpecial ? "—" : ":";
        String originalString = home_scores+"\t"+divider+"\t"+away_scores;
        SpannableString styleText = new SpannableString(originalString);
        styleText.setSpan(new AbsoluteSizeSpan(textSize,true),0,originalString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        return styleText;
    }

    public int getTextColor(){
        if(status == -1 || status == 0){
            return Color.GRAY;
        }else{
            return Color.RED;
        }
    }

    public String getMiddleText(){
        if(status == -1){
            return "已结束";
        }else if(status == 0){
            return "竞猜";
        }else{
            return null;
        }
    }

    public int getEndVisibility(){
        if(status == -1 || status == 0){
            return View.VISIBLE;
        }else{
            return View.GONE;
        }

    }
}
